
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>Effective Java笔记 · 梦里茶</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.2">
        <meta name="author" content="陈伟航">
        
        
    
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-disqus/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-toggle-chapters/toggle.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
        <link rel="stylesheet" href="../../styles/website.css">
        
    
        
    
        
    
        
    
        
    
        
    


    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="../../backend/" />
    
    
    <link rel="prev" href="../note.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../">
            
                <a href="../../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../../android/">
            
                <a href="../../android/">
            
                    
                    Android
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../../android/activity/">
            
                <a href="../../android/activity/">
            
                    
                    activity
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1.1" data-path="../../android/activity/Activity四种启动模式.html">
            
                <a href="../../android/activity/Activity四种启动模式.html">
            
                    
                    Activity四种启动模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.1.2" data-path="../../android/activity/INTENT_FLAG.html">
            
                <a href="../../android/activity/INTENT_FLAG.html">
            
                    
                    Intent Flag
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.1.3" data-path="../../android/activity/多TASK的应用.html">
            
                <a href="../../android/activity/多TASK的应用.html">
            
                    
                    多task的应用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.1.4" data-path="../../android/activity/Task和回退栈.html">
            
                <a href="../../android/activity/Task和回退栈.html">
            
                    
                    Task和回退栈
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../../android/sqlite/">
            
                <a href="../../android/sqlite/">
            
                    
                    sqlite
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.2.1" data-path="../../android/sqlite/从源码看ANDROID中SQLITE是怎么通过CURSORWINDOW读DB的.html">
            
                <a href="../../android/sqlite/从源码看ANDROID中SQLITE是怎么通过CURSORWINDOW读DB的.html">
            
                    
                    【源码】CursorWindow读DB
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2.2" data-path="../../android/sqlite/SQLITE在ANDROID上的一个BUG.html">
            
                <a href="../../android/sqlite/SQLITE在ANDROID上的一个BUG.html">
            
                    
                    Sqlite在Android上的一个Bug
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../../android/chromium/">
            
                <a href="../../android/chromium/">
            
                    
                    Chromium
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="../../android/listview_db.html">
            
                <a href="../../android/listview_db.html">
            
                    
                    ListView读取DB数据最佳实践
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.5" data-path="../../android/Android_project结构.html">
            
                <a href="../../android/Android_project结构.html">
            
                    
                    Android Project结构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.6" data-path="../../android/一个由PROGUARD与FASTJSON引起的血案.html">
            
                <a href="../../android/一个由PROGUARD与FASTJSON引起的血案.html">
            
                    
                    一个由Proguard与FastJson引起的血案
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.7" data-path="../../android/note.html">
            
                <a href="../../android/note.html">
            
                    
                    琐碎的一些tips
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../../ml/">
            
                <a href="../../ml/">
            
                    
                    Machine Learning
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../../ml/trick/">
            
                <a href="../../ml/trick/">
            
                    
                    技巧
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1.1" data-path="../../ml/trick/imgnet_1h.html">
            
                <a href="../../ml/trick/imgnet_1h.html">
            
                    
                    FaceBook: 1 hour training ImageNet
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.1.2" data-path="../../ml/trick/l2_normalize.html">
            
                <a href="../../ml/trick/l2_normalize.html">
            
                    
                    L2 Norm与L2 normalize
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../../ml/pratice/ncs.html">
            
                <a href="../../ml/pratice/ncs.html">
            
                    
                    实践
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../../ml/kit/">
            
                <a href="../../ml/kit/">
            
                    
                    工具
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.3.1" >
            
                <a target="_blank" href="https://github.com/ahangchen/GDLNotes">
            
                    
                    Tensorflow学习笔记
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3.2" data-path="../../ml/kit/caffe/mscnn.html">
            
                <a href="../../ml/kit/caffe/mscnn.html">
            
                    
                    mscnn
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3.3" data-path="../../ml/matlab/">
            
                <a href="../../ml/matlab/">
            
                    
                    Matlab
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.3.3.1" data-path="../../ml/matlab/ripc_auto.html">
            
                <a href="../../ml/matlab/ripc_auto.html">
            
                    
                    Matlab Remote IPC自动化数据处理
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="../../ml/papers/">
            
                <a href="../../ml/papers/">
            
                    
                    讲座论文系列
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.4.1" data-path="../../ml/reid/">
            
                <a href="../../ml/reid/">
            
                    
                    Re-identification
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.4.1.1" data-path="../../ml/papers/TFusion.html">
            
                <a href="../../ml/papers/TFusion.html">
            
                    
                    CVPR2018:TFusion完全解读
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4.1.2" data-path="../../ml/reid/reid.html">
            
                <a href="../../ml/reid/reid.html">
            
                    
                    Person Re-identification
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4.1.3" data-path="../../ml/reid/cvpr-reid.html">
            
                <a href="../../ml/reid/cvpr-reid.html">
            
                    
                    CVPR2016 Re-id
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4.1.4" data-path="../../ml/reid/reid-topo.html">
            
                <a href="../../ml/reid/reid-topo.html">
            
                    
                    Camera topology and Person Re-id
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4.1.5" data-path="../../ml/reid/deep_transfer_learning_person_reid.html">
            
                <a href="../../ml/reid/deep_transfer_learning_person_reid.html">
            
                    
                    Deep transfer learning Person Re-id
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4.1.6" data-path="../../ml/reid/evaluate.html">
            
                <a href="../../ml/reid/evaluate.html">
            
                    
                    Evaluate
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3.4.2" data-path="../../ml/papers/detection/">
            
                <a href="../../ml/papers/detection/">
            
                    
                    Object Detection
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.4.2.1" data-path="../../ml/papers/detection/rcnn.html">
            
                <a href="../../ml/papers/detection/rcnn.html">
            
                    
                    读论文系列·干货满满的RCNN
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4.2.2" data-path="../../ml/papers/detection/sppnet.html">
            
                <a href="../../ml/papers/detection/sppnet.html">
            
                    
                    读论文系列·SPP-net
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4.2.3" data-path="../../ml/papers/detection/fast_rcnn.html">
            
                <a href="../../ml/papers/detection/fast_rcnn.html">
            
                    
                    读论文系列·Fast RCNN
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4.2.4" data-path="../../ml/papers/detection/faster_rcnn.html">
            
                <a href="../../ml/papers/detection/faster_rcnn.html">
            
                    
                    读论文系列·Faster RCNN
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4.2.5" data-path="../../ml/papers/detection/yolo.html">
            
                <a href="../../ml/papers/detection/yolo.html">
            
                    
                    读论文系列·YOLO
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4.2.6" data-path="../../ml/papers/detection/ssd.html">
            
                <a href="../../ml/papers/detection/ssd.html">
            
                    
                    读论文系列·SSD
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4.2.7" data-path="../../ml/papers/detection/yolo23.html">
            
                <a href="../../ml/papers/detection/yolo23.html">
            
                    
                    读论文系列·YOLOv2 & YOLOv3
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4.2.8" data-path="../../ml/papers/detection/other.html">
            
                <a href="../../ml/papers/detection/other.html">
            
                    
                    读论文系列·detection其他文章推荐
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3.4.3" >
            
                <span>
            
                    
                    Hashing
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.4.3.1" data-path="../../ml/papers/hashing/ssah.html">
            
                <a href="../../ml/papers/hashing/ssah.html">
            
                    
                    CVPR2018: SSAH
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3.4.4" >
            
                <span>
            
                    
                    大杂烩
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.4.4.1" data-path="../../ml/papers/cncc2017.html">
            
                <a href="../../ml/papers/cncc2017.html">
            
                    
                    CNCC2017 琐记
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4.4.2" data-path="../../ml/papers/eccv2016_hydra_ccnn.html">
            
                <a href="../../ml/papers/eccv2016_hydra_ccnn.html">
            
                    
                    ECCV 2016 Hydra CCNN
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4.4.3" data-path="../../ml/papers/cncc_cv.html">
            
                <a href="../../ml/papers/cncc_cv.html">
            
                    
                    CNCC2017深度学习与跨媒体智能
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4.4.4" data-path="../../ml/papers/mla_2016.html">
            
                <a href="../../ml/papers/mla_2016.html">
            
                    
                    MLA2016笔记
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="../../ml/zzh_ml_notes.html">
            
                <a href="../../ml/zzh_ml_notes.html">
            
                    
                    《机器学习》（周志华）读书笔记
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.5.1" data-path="../../ml/melon/">
            
                <a href="../../ml/melon/">
            
                    
                    西瓜书概念整理
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.5.1.1" data-path="../../ml/melon/ch01.html">
            
                <a href="../../ml/melon/ch01.html">
            
                    
                    绪论
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5.1.2" data-path="../../ml/melon/ch02.html">
            
                <a href="../../ml/melon/ch02.html">
            
                    
                    模型评估与选择
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5.1.3" data-path="../../ml/melon/ch03.html">
            
                <a href="../../ml/melon/ch03.html">
            
                    
                    线性模型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5.1.4" data-path="../../ml/melon/ch04.html">
            
                <a href="../../ml/melon/ch04.html">
            
                    
                    决策树
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5.1.5" data-path="../../ml/melon/ch05.html">
            
                <a href="../../ml/melon/ch05.html">
            
                    
                    神经网络
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5.1.6" data-path="../../ml/melon/ch06.html">
            
                <a href="../../ml/melon/ch06.html">
            
                    
                    支持向量机
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5.1.7" data-path="../../ml/melon/ch07.html">
            
                <a href="../../ml/melon/ch07.html">
            
                    
                    贝叶斯分类器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5.1.8" data-path="../../ml/melon/ch08.html">
            
                <a href="../../ml/melon/ch08.html">
            
                    
                    集成学习
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5.1.9" data-path="../../ml/melon/ch09.html">
            
                <a href="../../ml/melon/ch09.html">
            
                    
                    聚类
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5.1.10" data-path="../../ml/melon/ch10.html">
            
                <a href="../../ml/melon/ch10.html">
            
                    
                    降维与度量学习
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5.1.11" data-path="../../ml/melon/ch11.html">
            
                <a href="../../ml/melon/ch11.html">
            
                    
                    特征选择与稀疏学习
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5.1.12" data-path="../../ml/melon/ch12.html">
            
                <a href="../../ml/melon/ch12.html">
            
                    
                    计算学习理论
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5.1.13" data-path="../../ml/melon/ch13.html">
            
                <a href="../../ml/melon/ch13.html">
            
                    
                    半监督学习
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5.1.14" data-path="../../ml/melon/ch14.html">
            
                <a href="../../ml/melon/ch14.html">
            
                    
                    概率图模型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5.1.15" data-path="../../ml/melon/ch15.html">
            
                <a href="../../ml/melon/ch15.html">
            
                    
                    规则学习
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5.1.16" data-path="../../ml/melon/ch16.html">
            
                <a href="../../ml/melon/ch16.html">
            
                    
                    强化学习
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5.1.17" data-path="../../ml/melon/ch17.html">
            
                <a href="../../ml/melon/ch17.html">
            
                    
                    附录
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../">
            
                <a href="../">
            
                    
                    Java
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../java-web/note.html">
            
                <a href="../java-web/note.html">
            
                    
                    java web
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1.1" data-path="../java-web/Servlet组织.html">
            
                <a href="../java-web/Servlet组织.html">
            
                    
                    Servlet部署
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.1.2" data-path="../java-web/note.html">
            
                <a href="../java-web/note.html">
            
                    
                    琐碎的tips
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../jni/note.html">
            
                <a href="../jni/note.html">
            
                    
                    JNI
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../note.html">
            
                <a href="../note.html">
            
                    
                    Note
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.4.4" data-path="l1-new-delete.html">
            
                <a href="l1-new-delete.html">
            
                    
                    Effective Java笔记
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../../backend/">
            
                <a href="../../backend/">
            
                    
                    后端开发
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../../backend/design.html">
            
                <a href="../../backend/design.html">
            
                    
                    架构设计
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../../backend/db.html">
            
                <a href="../../backend/db.html">
            
                    
                    数据库
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../java-web/note.html">
            
                <a href="../java-web/note.html">
            
                    
                    java web
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.3.1" data-path="../java-web/Servlet组织.html">
            
                <a href="../java-web/Servlet组织.html">
            
                    
                    Servlet部署
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3.2" data-path="../java-web/note.html">
            
                <a href="../java-web/note.html">
            
                    
                    琐碎的tips
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="../../backend/spring_boot.html">
            
                <a href="../../backend/spring_boot.html">
            
                    
                    Spring boot
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="../../python/django/note.html">
            
                <a href="../../python/django/note.html">
            
                    
                    django
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.6" data-path="../../backend/concurrent.html">
            
                <a href="../../backend/concurrent.html">
            
                    
                    分布式
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../../linux/note.html">
            
                <a href="../../linux/note.html">
            
                    
                    Linux && Hardware
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../../linux/ubuntu_init.html">
            
                <a href="../../linux/ubuntu_init.html">
            
                    
                    Ubuntu安装与初始配置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../../linux/raspbian/">
            
                <a href="../../linux/raspbian/">
            
                    
                    树莓派相关
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.2.1" data-path="../../linux/raspbian/rtlwifi.html">
            
                <a href="../../linux/raspbian/rtlwifi.html">
            
                    
                    树莓派3B+无线网卡监听模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2.2" data-path="../../linux/raspbian/tlwr703n_openwrt.html">
            
                <a href="../../linux/raspbian/tlwr703n_openwrt.html">
            
                    
                    TP-LINK TL-WR703N v1.7 openwrt flashing
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../../python/">
            
                <a href="../../python/">
            
                    
                    Python
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../../python/django/note.html">
            
                <a href="../../python/django/note.html">
            
                    
                    django
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="../../python/raw.html">
            
                <a href="../../python/raw.html">
            
                    
                    原生模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3" data-path="../../python/design.html">
            
                <a href="../../python/design.html">
            
                    
                    设计模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.4" data-path="../../python/viz.html">
            
                <a href="../../python/viz.html">
            
                    
                    可视化
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.5" data-path="../../python/libs.html">
            
                <a href="../../python/libs.html">
            
                    
                    常用库踩坑指南
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../../web-front/">
            
                <a href="../../web-front/">
            
                    
                    web前端
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.8.1" data-path="../../web-front/head_content.html">
            
                <a href="../../web-front/head_content.html">
            
                    
                    header div固定，content div填充父容器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.2" data-path="../../web-front/json_res.html">
            
                <a href="../../web-front/json_res.html">
            
                    
                    json接口资源
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../../UI/">
            
                <a href="../../UI/">
            
                    
                    UI
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="../../kit/">
            
                <a href="../../kit/">
            
                    
                    kit
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.10.1" data-path="../../kit/vim/note.html">
            
                <a href="../../kit/vim/note.html">
            
                    
                    vim
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.2" data-path="../../kit/git/note.html">
            
                <a href="../../kit/git/note.html">
            
                    
                    git/github
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.10.2.1" data-path="../../kit/git/green_blush.html">
            
                <a href="../../kit/git/green_blush.html">
            
                    
                    刷爆github小绿点
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.10.3" data-path="../../kit/markdown/">
            
                <a href="../../kit/markdown/">
            
                    
                    Markdown/gitbook
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.10.3.1" data-path="../../kit/markdown/pieces.html">
            
                <a href="../../kit/markdown/pieces.html">
            
                    
                    琐碎知识点
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.3.2" data-path="../../kit/markdown/gitbook_disqus.html">
            
                <a href="../../kit/markdown/gitbook_disqus.html">
            
                    
                    gitbook添加disqus作为评论
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.3.3" data-path="../../kit/markdown/chrome_mark2_md.html">
            
                <a href="../../kit/markdown/chrome_mark2_md.html">
            
                    
                    导出chrome书签为Markdown
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.3.4" data-path="../../kit/markdown/wx_md.html">
            
                <a href="../../kit/markdown/wx_md.html">
            
                    
                    Markdown here && 微信公众号
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.10.4" data-path="../../kit/latex/">
            
                <a href="../../kit/latex/">
            
                    
                    LaTex
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.10.4.1" data-path="../../kit/latex/note.html">
            
                <a href="../../kit/latex/note.html">
            
                    
                    LaTex琐记
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.10.5" data-path="../../kit/ss/">
            
                <a href="../../kit/ss/">
            
                    
                    科学上网
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="../../thinking-in-program/">
            
                <a href="../../thinking-in-program/">
            
                    
                    thinking-in-program
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.11.1" data-path="../../thinking-in-program/log.html">
            
                <a href="../../thinking-in-program/log.html">
            
                    
                    怎样打日志
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="../../star.html">
            
                <a href="../../star.html">
            
                    
                    我的收藏
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="../../pieces.html">
            
                <a href="../../pieces.html">
            
                    
                    琐记
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.13.1" data-path="../../paper.html">
            
                <a href="../../paper.html">
            
                    
                    论文心得
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.14" data-path="../../support.html">
            
                <a href="../../support.html">
            
                    
                    打赏支持
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >Effective Java笔记</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="&#x521B;&#x5EFA;&#x548C;&#x9500;&#x6BC1;&#x5BF9;&#x8C61;">&#x521B;&#x5EFA;&#x548C;&#x9500;&#x6BC1;&#x5BF9;&#x8C61;</h1>
<h2 id="&#x9759;&#x6001;&#x5DE5;&#x5382;&#x65B9;&#x6CD5;&#x4EE3;&#x66FF;&#x6784;&#x9020;&#x5668;">&#x9759;&#x6001;&#x5DE5;&#x5382;&#x65B9;&#x6CD5;&#x4EE3;&#x66FF;&#x6784;&#x9020;&#x5668;</h2>
<ul>
<li>&#x6709;&#x540D;&#x79F0;&#xFF0C;&#x63A5;&#x53E3;&#x6BD4;&#x6784;&#x9020;&#x5668;&#x66F4;&#x6613;&#x61C2;</li>
</ul>
<blockquote>
<p>BigInteger.probablePrime</p>
</blockquote>
<ul>
<li>&#x53EF;&#x4EE5;&#x5B9E;&#x73B0;&#x5355;&#x4F8B;&#x3001;&#x5BF9;&#x8C61;&#x6C60;&#x3001;&#x5185;&#x5B58;&#x91CD;&#x7528;</li>
</ul>
<blockquote>
<p>&#x5355;&#x4F8B;&#x6A21;&#x5F0F;</p>
</blockquote>
<ul>
<li><p>&#x53EF;&#x4EE5;&#x8FD4;&#x56DE;return&#x7C7B;&#x578B;&#x7684;&#x5B50;&#x7C7B;&#xFF0C;&#x9762;&#x5411;&#x63A5;&#x53E3;&#x7F16;&#x7A0B;</p>
<ul>
<li>&#x53EF;&#x4EE5;&#x8BA9;&#x8FD4;&#x56DE;&#x7684;&#x7C7B;&#x975E;public</li>
<li>&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x4E0D;&#x540C;&#x7684;&#x5DE5;&#x5382;&#x65B9;&#x6CD5;&#x8FD4;&#x56DE;&#x4E0D;&#x540C;&#x5B50;&#x7C7B;</li>
</ul>
<blockquote>
<p>Java Collections Framework</p>
</blockquote>
</li>
<li><p>&#x5229;&#x7528;&#x7C7B;&#x578B;&#x63A8;&#x5BFC;&#xFF0C;&#x7B80;&#x5316;&#x6A21;&#x677F;&#x53C2;&#x6570;</p>
<pre><code class="lang-java">Map&lt;String, List&lt;String&gt;&gt; m = HashMap.newInstance();
</code></pre>
</li>
<li>&#x7531;&#x4E8E;&#x8FD4;&#x56DE;&#x7684;&#x5B50;&#x7C7B;&#x578B;&#x662F;private&#xFF0C;&#x5C31;&#x65E0;&#x6CD5;&#x76F4;&#x63A5;&#x5B9E;&#x4F8B;&#x5316;&#x8FD9;&#x4E9B;&#x5B50;&#x7C7B;&#x578B;</li>
<li>&#x9759;&#x6001;&#x5DE5;&#x5382;&#x65B9;&#x6CD5;&#x5728;Javadoc&#x4E2D;&#x6CA1;&#x6709;&#x8FA8;&#x8BC6;&#x5EA6;</li>
<li>&#x5E38;&#x7528;&#x540D;&#x79F0;&#xFF1A;<blockquote>
<p>valueOf, of, getInstance, newInstance, getType, newType</p>
</blockquote>
</li>
</ul>
<h2 id="&#x6784;&#x9020;&#x53C2;&#x6570;&#x591A;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x4F7F;&#x7528;builder">&#x6784;&#x9020;&#x53C2;&#x6570;&#x591A;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x4F7F;&#x7528;Builder</h2>
<ul>
<li>M1: &#x591A;&#x53C2;&#x6570;&#x91CD;&#x8F7D;&#x6784;&#x9020;&#x51FD;&#x6570;<blockquote>
<p>&#x4EE3;&#x7801;&#x53EF;&#x8BFB;&#x6027;&#x5DEE;</p>
</blockquote>
</li>
<li>M2&#xFF1A;Java Bean&#xFF08;setter&#xFF0C;getter&#xFF09;<ul>
<li>&#x7B80;&#x5355;</li>
<li>set&#x8FC7;&#x7A0B;&#x4E2D;&#x5BF9;&#x8C61;&#x5C5E;&#x6027;&#x4E0D;&#x5B8C;&#x6574;</li>
<li>&#x4E0D;&#x80FD;&#x5355;&#x4F8B;&#x5316;</li>
</ul>
</li>
<li><p>M3:Builder</p>
<pre><code class="lang-java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Line</span> </span>{
  <span class="hljs-keyword">private</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> length;
  <span class="hljs-keyword">private</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> id;
  <span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Builder</span> </span>{
      <span class="hljs-keyword">private</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> id;
      <span class="hljs-keyword">private</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> length = <span class="hljs-number">0</span>;
      <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-title">Builder</span><span class="hljs-params">(<span class="hljs-keyword">int</span> id)</span> </span>{
          <span class="hljs-keyword">this</span>.id = id;
      }

      <span class="hljs-function"><span class="hljs-keyword">public</span> Builder <span class="hljs-title">length</span><span class="hljs-params">(<span class="hljs-keyword">int</span> len)</span> </span>{
          length = len;
          <span class="hljs-keyword">return</span> <span class="hljs-keyword">this</span>;
      }
      <span class="hljs-function"><span class="hljs-keyword">public</span> Line <span class="hljs-title">build</span><span class="hljs-params">()</span> </span>{
          <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> Line(<span class="hljs-keyword">this</span>);
      }
  }
  <span class="hljs-function"><span class="hljs-keyword">private</span> <span class="hljs-title">Line</span><span class="hljs-params">(Builder builder)</span> </span>{
      id = builder.id;
      length = builder.length;
  }
  <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">void</span> <span class="hljs-title">main</span><span class="hljs-params">(String[]args)</span> </span>{
      Line line = <span class="hljs-keyword">new</span> Line.Builder(<span class="hljs-number">0</span>).length(<span class="hljs-number">1</span>).build();
  }
}
</code></pre>
<ul>
<li>&#x4F20;&#x9012;&#x6784;&#x9020;&#x53C2;&#x6570;&#x65F6;&#x50CF;setter&#x4E00;&#x6837;&#x660E;&#x786E;</li>
<li>build()&#x8C03;&#x7528;&#x6784;&#x9020;&#x5668;&#x65F6;&#xFF0C;&#x53EF;&#x4EE5;&#x6267;&#x884C;&#x53C2;&#x6570;&#x68C0;&#x67E5;&#x8FDB;&#x884C;&#x7EA6;&#x675F;&#xFF0C;&#x5728;build&#x4E4B;&#x540E;&#x624D;&#x4F7F;&#x7528;&#x8FD4;&#x56DE;&#x7C7B;&#xFF0C;&#x5C31;&#x80FD;&#x4FDD;&#x8BC1;&#x5C5E;&#x6027;&#x7684;&#x5B8C;&#x6574;&#x6027;&#x3002;</li>
<li>&#x53EF;&#x4EE5;&#x5411;Builder&#x4F20;&#x9012;&#x6A21;&#x677F;&#x53C2;&#x6570;&#xFF0C;&#x8BA9;&#x5B83;&#x7684;build()&#x65B9;&#x6CD5;&#x8FD4;&#x56DE;&#x4EFB;&#x610F;&#x7C7B;&#x578B;</li>
<li>Class.newInstance&#x8C03;&#x7528;&#x65E0;&#x53C2;&#x6784;&#x9020;&#x51FD;&#x6570;&#xFF0C;&#x4F46;&#x65E0;&#x53C2;&#x6784;&#x9020;&#x51FD;&#x6570;&#x4E0D;&#x5B58;&#x5728;&#x65F6;&#xFF0C;&#x7F16;&#x8BD1;&#x4E0D;&#x4F1A;&#x62A5;&#x9519;&#xFF0C;&#x800C;Builder&#x7684;&#x68C0;&#x67E5;&#x5219;&#x5F25;&#x8865;&#x4E86;&#x8FD9;&#x4E00;&#x70B9;&#x3002;</li>
</ul>
</li>
</ul>
<h2 id="&#x79C1;&#x6709;&#x6784;&#x9020;&#x5668;&#x6216;&#x679A;&#x4E3E;&#x7C7B;&#x578B;&#x5B9E;&#x73B0;&#x5355;&#x4F8B;">&#x79C1;&#x6709;&#x6784;&#x9020;&#x5668;&#x6216;&#x679A;&#x4E3E;&#x7C7B;&#x578B;&#x5B9E;&#x73B0;&#x5355;&#x4F8B;</h2>
<ul>
<li>M1&#xFF1A;<pre><code class="lang-java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Elvis</span> </span>{
  <span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> Elvis INSTANCE = <span class="hljs-keyword">new</span> Elvis();
  <span class="hljs-function"><span class="hljs-keyword">private</span> <span class="hljs-title">Elvis</span><span class="hljs-params">()</span> </span>{}
  <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">leaveTheBuilding</span><span class="hljs-params">()</span></span>{}
}
</code></pre>
</li>
</ul>
<blockquote>
<p>&#x53CD;&#x5C04;&#x53EF;&#x4EE5;&#x8C03;&#x7528;&#x5230;&#x79C1;&#x6709;&#x7684;&#x6784;&#x9020;&#x5668;</p>
</blockquote>
<ul>
<li>M2:<pre><code class="lang-java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Elvis</span> </span>{
  <span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> Elvis INSTANCE = <span class="hljs-keyword">new</span> Elvis();
  <span class="hljs-function"><span class="hljs-keyword">private</span> <span class="hljs-title">Elvis</span><span class="hljs-params">()</span> </span>{}
  <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> Elvis <span class="hljs-title">getInstance</span><span class="hljs-params">()</span> </span>{<span class="hljs-keyword">return</span> INSTANCE;}
  <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">leaveTheBuilding</span><span class="hljs-params">()</span> </span>{}
}
</code></pre>
</li>
</ul>
<blockquote>
<p>&#x7075;&#x6D3B;&#xFF0C;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x4FEE;&#x6539;getInstance()&#x65B9;&#x6CD5;&#xFF0C;&#x51B3;&#x5B9A;&#x662F;&#x5426;&#x8FD4;&#x56DE;&#x5355;&#x4F8B;&#x5BF9;&#x8C61;</p>
</blockquote>
<ul>
<li>&#x9632;&#x6B62;&#x53CD;&#x5E8F;&#x5217;&#x5316;&#x51FA;&#x9519;<pre><code class="lang-java"><span class="hljs-function"><span class="hljs-keyword">private</span> Object <span class="hljs-title">readResolve</span><span class="hljs-params">()</span> </span>{
  <span class="hljs-keyword">return</span> INSTANCE;
}
</code></pre>
</li>
<li>&#x679A;&#x4E3E;&#x5355;&#x4F8B;&#xFF08;Java 1.5&#xFF09;<pre><code class="lang-java"><span class="hljs-keyword">public</span> <span class="hljs-keyword">enum</span> Elvis {
  INSTANCE;
  <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">leaveTheBuilding</span><span class="hljs-params">()</span> </span>{}
}
</code></pre>
</li>
</ul>
<blockquote>
<p>&#x7B80;&#x6D01;&#xFF0C;&#x5E8F;&#x5217;&#x5316;&#xFF0C;&#x9632;&#x6B62;&#x591A;&#x5B9E;&#x4F8B;&#x5316;&#xFF0C;&#x6700;&#x4F73;&#x65B9;&#x6CD5;</p>
</blockquote>
<h2 id="&#x79C1;&#x6709;&#x6784;&#x9020;&#x5668;&#x5F3A;&#x5316;&#x4E0D;&#x53EF;&#x5B9E;&#x4F8B;&#x5316;">&#x79C1;&#x6709;&#x6784;&#x9020;&#x5668;&#x5F3A;&#x5316;&#x4E0D;&#x53EF;&#x5B9E;&#x4F8B;&#x5316;</h2>
<p>&#x53EA;&#x5305;&#x542B;static method&#x548C;static field&#x7684;&#x5BF9;&#x8C61;&#x4E0D;&#x5E0C;&#x671B;&#x88AB;&#x5B9E;&#x4F8B;&#x5316;&#xFF0C;&#x4F46;&#x5B9E;&#x9645;&#x4E0A;&#x5B83;&#x6709;&#x9ED8;&#x8BA4;&#x7684;&#x65E0;&#x53C2;&#x6784;&#x9020;&#x5668;&#xFF0C;&#x6211;&#x4EEC;&#x4ECD;&#x7136;&#x53EF;&#x80FD;&#x5B9E;&#x4F8B;&#x5316;&#x5B83;&#x3002;</p>
<p>&#x56E0;&#x6B64;&#x901A;&#x8FC7;&#x5C06;&#x6784;&#x9020;&#x5668;&#x53D8;&#x4E3A;&#x79C1;&#x6709;&#x9632;&#x6B62;&#x5B9E;&#x4F8B;&#x5316;&#x3002;</p>
<pre><code class="lang-java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">UtilityClass</span> </span>{
    <span class="hljs-function"><span class="hljs-keyword">private</span> <span class="hljs-title">UtilityClass</span><span class="hljs-params">()</span> </span>{
        <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> AssertionError();
    }
}
</code></pre>
<p>&#x8FD9;&#x79CD;&#x65B9;&#x6CD5;&#x7684;&#x4E00;&#x4E2A;&#x7F3A;&#x70B9;&#x662F;&#xFF0C;&#x8FD9;&#x79CD;&#x5DE5;&#x5177;&#x7C7B;&#x65E0;&#x6CD5;&#x88AB;&#x5B50;&#x7C7B;&#x5316;&#x3002;</p>
<h2 id="&#x907F;&#x514D;&#x521B;&#x5EFA;&#x4E0D;&#x5FC5;&#x8981;&#x7684;&#x5BF9;&#x8C61;">&#x907F;&#x514D;&#x521B;&#x5EFA;&#x4E0D;&#x5FC5;&#x8981;&#x7684;&#x5BF9;&#x8C61;</h2>
<ul>
<li><p>String</p>
<pre><code class="lang-java">String s = <span class="hljs-keyword">new</span> String(<span class="hljs-string">&quot;test&quot;</span>);
</code></pre>
<p>&#x4E0A;&#x9762;&#x8FD9;&#x79CD;&#x5199;&#x6CD5;&#x6BCF;&#x6B21;&#x90FD;&#x4F1A;&#x91CD;&#x65B0;&#x521B;&#x5EFA;&#x4E24;&#x4E2A;String&#x5BF9;&#x8C61;</p>
<pre><code class="lang-java">String s = <span class="hljs-string">&quot;test&quot;</span>;
</code></pre>
<p>JTS 3.10.5&#x4FDD;&#x8BC1;&#x4E86;&#x76F8;&#x540C;&#x5185;&#x5BB9;&#x7684;&#x5B57;&#x7B26;&#x4E32;&#x91CD;&#x7528;&#x540C;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;&#xFF0C;&#x800C;&#x4E14;&#x53EA;&#x521B;&#x5EFA;&#x4E00;&#x6B21;&#x3002;</p>
</li>
<li><p>&#x5EF6;&#x8FDF;&#x521D;&#x59CB;&#x5316;</p>
</li>
<li>&#x5355;&#x4F8B;</li>
<li>&#x5BF9;&#x8C61;&#x6C60;</li>
<li>&#x591A;&#x6001;&#x5C42;&#x8FDE;&#x63A5;&#x5355;&#x4F8B;&#x5C42;&#xFF0C;&#x4E0D;&#x9700;&#x8981;&#x4E3A;&#x6BCF;&#x4E2A;&#x591A;&#x6001;&#x5C42;&#x521B;&#x5EFA;&#x591A;&#x4E2A;&#x5355;&#x4F8B;&#x5C42;</li>
<li>static&#x6267;&#x884C;&#x5F00;&#x9500;&#x5927;&#x7684;&#x4EE3;&#x7801;&#x5757;&#xFF0C;&#x5B58;&#x50A8;&#x6267;&#x884C;&#x7ED3;&#x679C;&#x91CD;&#x7528;</li>
<li>&#x5BF9;&#x4E8E;&#x4E00;&#x4E2A;&#x7C7B;&#x4E2D;&#xFF0C;&#x521B;&#x5EFA;&#x5F00;&#x9500;&#x5927;&#xFF0C;&#x521B;&#x5EFA;&#x540E;&#x4E0D;&#x4FEE;&#x6539;&#xFF0C;&#x4F46;&#x4F1A;&#x591A;&#x6B21;&#x8BFB;&#x53D6;&#x7684;&#x5BF9;&#x8C61;&#xFF0C;&#x9002;&#x5408;</li>
<li>&#x4F46;&#x5982;&#x679C;static&#x521B;&#x5EFA;&#x7684;&#x5BF9;&#x8C61;&#x5F88;&#x5C11;&#x4F7F;&#x7528;&#xFF0C;&#x53EF;&#x4EE5;&#x8003;&#x8651;&#x5EF6;&#x8FDF;&#x521D;&#x59CB;&#x5316;&#xFF0C;&#x4F46;&#x5EF6;&#x8FDF;&#x521D;&#x59CB;&#x5316;&#x5B9E;&#x73B0;&#x590D;&#x6742;&#xFF0C;&#x4E5F;&#x4F1A;&#x5F71;&#x54CD;&#x6027;&#x80FD;</li>
<li>&#x6709;&#x4E9B;&#x5BF9;&#x8C61;&#x521D;&#x59CB;&#x5316;&#x540E;&#x53EF;&#x80FD;&#x6539;&#x53D8;&#xFF0C;&#x4F46;&#x6539;&#x53D8;&#x540E;&#x5176;&#x529F;&#x80FD;&#x662F;&#x4E0D;&#x53D8;&#x7684;&#xFF0C;&#x5E94;&#x5F53;&#x4FDD;&#x6301;&#x5B83;&#x4E3A;&#x4E00;&#x4E2A;&#x786E;&#x5B9A;&#x7684;&#x5F15;&#x7528;&#xFF0C;&#x7136;&#x540E;&#x6539;&#x53D8;&#x5F15;&#x7528;&#x6240;&#x6307;&#x5BF9;&#x8C61;&#x7684;&#x5185;&#x5BB9;&#xFF0C;&#x5982;Map&#x4E2D;&#x7684;keySet</li>
<li>&#x4F18;&#x5148;&#x4F7F;&#x7528;&#x57FA;&#x672C;&#x7C7B;&#x578B;&#xFF08;int&#xFF09;&#x800C;&#x975E;&#x88C5;&#x7BB1;&#x57FA;&#x672C;&#x7C7B;&#x578B;(Integer)&#xFF0C;&#x6027;&#x80FD;&#x4F18;&#x5316;</li>
<li>&#x91CD;&#x5BF9;&#x8C61;&#x624D;&#x6709;&#x5FC5;&#x8981;&#x5C3D;&#x53EF;&#x80FD;&#x907F;&#x514D;&#x521B;&#x5EFA;&#xFF0C;&#x5C0F;&#x5BF9;&#x8C61;&#x53EF;&#x4EE5;&#x7531;JVM&#x5F88;&#x5BB9;&#x6613;&#x5730;&#x6784;&#x9020;&#x548C;&#x9500;&#x6BC1;&#xFF0C;&#x6BD4;&#x81EA;&#x5DF1;&#x7EF4;&#x62A4;&#x5BF9;&#x8C61;&#x6C60;&#x8981;&#x597D;&#x5F97;&#x591A;</li>
</ul>
<h2 id="&#x5F15;&#x7528;&#x6CC4;&#x9732;">&#x5F15;&#x7528;&#x6CC4;&#x9732;</h2>
<p>java&#x4E2D;&#x6CA1;&#x6709;&#x5185;&#x5B58;&#x6CC4;&#x9732;&#xFF0C;&#x53EA;&#x6709;&#x5F15;&#x7528;&#x6CC4;&#x9732;&#x3002;&#x6BD4;&#x5982;&#x4E00;&#x4E2A;Stack&#x7684;&#x5B9E;&#x73B0;&#xFF1A;</p>
<pre><code class="lang-java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Stack</span> </span>{
    <span class="hljs-keyword">private</span> Object[] elements;
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">int</span> size = <span class="hljs-number">0</span>;
    <span class="hljs-comment">// ...</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> Object <span class="hljs-title">pop</span><span class="hljs-params">()</span> </span>{
        <span class="hljs-keyword">return</span> elements[--size];
    }

}
</code></pre>
<p>&#x8FD9;&#x91CC;&#x7684;pop&#x64CD;&#x4F5C;&#x53EA;&#x6539;&#x53D8;&#x4E86;size&#xFF0C;&#x800C;&#x6CA1;&#x6709;&#x5C06;elements[size-1]&#x7684;&#x5F15;&#x7528;&#x79FB;&#x9664;&#xFF0C;Stack&#x5BF9;&#x8C61;&#x4E00;&#x76F4;&#x6301;&#x6709;element&#x7684;&#x5F15;&#x7528;&#xFF0C;&#x5E94;&#x8BE5;&#x6539;&#x4E3A;&#xFF1A;</p>
<pre><code class="lang-java"><span class="hljs-function"><span class="hljs-keyword">public</span> Object <span class="hljs-title">pop</span><span class="hljs-params">()</span> </span>{
    Object result = elements[--size];
    elemets[size] = <span class="hljs-keyword">null</span>;
    <span class="hljs-keyword">return</span> result;
}
</code></pre>
<p>&#x901A;&#x8FC7;&#x7F6E;null&#x53BB;&#x6389;stack&#x4E2D;elements&#x6570;&#x7EC4;&#x5BF9;element&#x5BF9;&#x8C61;&#x7684;&#x5F15;&#x7528;</p>
<blockquote>
<p>&#x5728;&#x8FD9;&#x4E2A;&#x4F8B;&#x5B50;&#x4E2D;&#xFF0C;&#x7531;&#x4E8E;Stack&#x662F;&#x81EA;&#x5DF1;&#x5728;&#x7BA1;&#x7406;&#x5185;&#x5B58;&#xFF0C;&#x5B58;&#x50A8;&#x6C60;&#x5305;&#x542B;&#x4E86;&#x5BF9;&#x8C61;&#x5F15;&#x7528;&#x5355;&#x5143;&#xFF08;&#x5373;elements&#x6570;&#x7EC4;&#xFF09;</p>
</blockquote>
<p>&#x9700;&#x8981;&#x8B66;&#x60D5;&#x5F15;&#x7528;&#x6CC4;&#x9732;&#x7684;&#x60C5;&#x5F62;&#xFF1A;</p>
<ul>
<li>&#x7C7B;&#x4E2D;&#x6709;&#x5BF9;&#x8C61;&#x5F15;&#x7528;&#x5355;&#x5143;</li>
<li>&#x7F13;&#x5B58;</li>
<li>&#x76D1;&#x542C;&#x5668;&#x4E0E;&#x56DE;&#x8C03;&#xFF1A;bind&#x800C;&#x6CA1;&#x6709;unbind&#xFF0C;&#x597D;&#x7684;&#x505A;&#x6CD5;&#x662F;&#x53EA;&#x4FDD;&#x5B58;&#x56DE;&#x8C03;&#x7684;&#x5F31;&#x5F15;&#x7528;&#x3002;</li>
</ul>
<h2 id="avoid-finalize">Avoid finalize</h2>
<ul>
<li>Note<ul>
<li>finalize&#x4E0D;&#x4FDD;&#x8BC1;&#x6267;&#x884C;&#xFF0C;&#x5C3D;&#x91CF;&#x4E0D;&#x8981;&#x7528;</li>
<li>System.gc&#x548C;System.runFinalization&#x53EA;&#x662F;&#x589E;&#x52A0;finalize&#x6267;&#x884C;&#x7684;&#x673A;&#x4F1A;</li>
<li>finalize&#x6709;&#x4E25;&#x91CD;&#x7684;&#x6027;&#x80FD;&#x635F;&#x5931;</li>
<li>&#x901A;&#x8FC7;try - catch - finally&#x6765;&#x663E;&#x5F0F;&#x91CA;&#x653E;&#x8D44;&#x6E90;</li>
</ul>
</li>
<li>&#x5408;&#x7406;&#x7528;&#x6CD5;<ul>
<li>&#x4F5C;&#x4E3A;&#x663E;&#x5F0F;&#x91CA;&#x653E;&#x8D44;&#x6E90;&#x7684;backup&#xFF0C;&#x6216;&#x8005;check</li>
<li>&#x56DE;&#x6536;native peer</li>
</ul>
</li>
<li>&#x7236;&#x7C7B;finalize<ul>
<li>&#x663E;&#x5F0F;&#x8C03;&#x7528;super.finalize()</li>
<li>&#x5185;&#x90E8;&#x7C7B;&#x5F3A;&#x5236;&#x5B50;&#x7C7B;&#x6267;&#x884C;
```java
public class Foo {
private final Object finalizeGuardian = new Object() {<pre><code>@Override protected void finalize() throws Throwable {
    Foo.finalize();
}
</code></pre>};
}</li>
</ul>
</li>
</ul>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="../note.html" class="navigation navigation-prev " aria-label="Previous page: Note">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="../../backend/" class="navigation navigation-next " aria-label="Next page: 后端开发">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"Effective Java笔记","level":"1.4.4","depth":2,"next":{"title":"后端开发","level":"1.5","depth":1,"path":"backend/README.md","ref":"backend/README.md","articles":[{"title":"架构设计","level":"1.5.1","depth":2,"path":"backend/design.md","ref":"backend/design.md","articles":[]},{"title":"数据库","level":"1.5.2","depth":2,"path":"backend/db.md","ref":"backend/db.md","articles":[]},{"title":"java web","level":"1.5.3","depth":2,"path":"java/java-web/note.md","ref":"java/java-web/note.md","articles":[{"title":"Servlet部署","level":"1.5.3.1","depth":3,"path":"java/java-web/Servlet组织.md","ref":"java/java-web/Servlet组织.md","articles":[]},{"title":"琐碎的tips","level":"1.5.3.2","depth":3,"path":"java/java-web/note.md","ref":"java/java-web/note.md","articles":[]}]},{"title":"Spring boot","level":"1.5.4","depth":2,"path":"backend/spring_boot.md","ref":"backend/spring_boot.md","articles":[]},{"title":"django","level":"1.5.5","depth":2,"path":"python/django/note.md","ref":"python/django/note.md","articles":[]},{"title":"分布式","level":"1.5.6","depth":2,"path":"backend/concurrent.md","ref":"backend/concurrent.md","articles":[]}]},"previous":{"title":"Note","level":"1.4.3","depth":2,"path":"java/note.md","ref":"java/note.md","articles":[]},"dir":"ltr"},"config":{"plugins":["disqus","github","toggle-chapters","mathjax","mermaid-gb3"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"disqus":{"useIdentifier":false,"shortName":"ahangchen-blog"},"github":{"url":"https://github.com/ahangchen/windy-afternoon"},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"mermaid-gb3":{},"mathjax":{"forceSVG":false,"version":"2.6-latest"},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"toggle-chapters":{}},"theme":"default","author":"陈伟航","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"梦里茶","gitbook":"*"},"file":{"path":"java/ej/l1-new-delete.md","mtime":"2017-06-21T09:19:23.000Z","type":"markdown"},"gitbook":{"version":"3.2.2","time":"2018-05-19T05:00:41.899Z"},"basePath":"../..","book":{"language":""}});
        });
    </script>
</div>

        
    
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="https://cdnjs.cloudflare.com/ajax/libs/URI.js/1.16.1/URI.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-disqus/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-github/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-toggle-chapters/toggle.js"></script>
        
    
        
        <script src="https://cdn.staticfile.org/mathjax/2.6.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-mathjax/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-mermaid-gb3/book/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    <script src="../../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.min.js"></script>

    </body>
</html>

